<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>贵金属置换率计算器</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 600px;
            margin: 2rem auto;
            padding: 0 1rem;
        }
        .calculator {
            background: #f5f5f5;
            padding: 2rem;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        .input-group {
            margin-bottom: 1.5rem;
        }
        label {
            display: block;
            margin-bottom: 0.5rem;
            color: #333;
        }
        input {
            width: 100%;
            padding: 0.8rem;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        button {
            background: #007bff;
            color: white;
            border: none;
            padding: 1rem 2rem;
            border-radius: 4px;
            cursor: pointer;
            width: 100%;
        }
        .result {
            margin-top: 1.5rem;
            padding: 1rem;
            background: #e9f5ff;
            border-radius: 4px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="calculator">
        <h2>三氯化钌置换率计算器</h2>
        
        <div class="input-group">
            <label for="factoryRate">厂家置换率（%）：</label>
            <input type="number" id="factoryRate" step="0.01" required>
        </div>

        <div class="input-group">
            <label for="processingFee">加工费（元/克）：</label>
            <input type="number" id="processingFee" step="0.01" required>
        </div>

        <div class="input-group">
            <label for="rutheniumPrice">三氯化钌价格（元/克）：</label>
            <input type="number" id="rutheniumPrice" step="0.01" required>
        </div>

        <button onclick="calculate()">计算综合置换率</button>

        <div class="result">
            <h3>综合置换率：<span id="result">--</span>%</h3>
        </div>
    </div>

    <script>
        function calculate() {
            // 获取输入值
            const factoryRate = parseFloat(document.getElementById('factoryRate').value);
            const processingFee = parseFloat(document.getElementById('processingFee').value);
            const rutheniumPrice = parseFloat(document.getElementById('rutheniumPrice').value);

            // 验证输入
            if (isNaN(factoryRate) || isNaN(processingFee) || isNaN(rutheniumPrice)) {
                alert("请填写所有有效数字");
                return;
            }

            if (rutheniumPrice === 0) {
                alert("三氯化钌价格不能为零");
                return;
            }

            // 计算公式
            const comprehensiveRate = factoryRate - (processingFee * 1.5616) / rutheniumPrice;
            
            // 显示结果（保留两位小数）
            document.getElementById('result').textContent = comprehensiveRate.toFixed(2);
        }
    </script>
</body>
</html>
